/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    const { INTEGER, STRING, DATE, ENUM, TEXT } = Sequelize;
    await queryInterface.createTable(
      "user",
      {
        id: {
          type: INTEGER,
          primaryKey: true,
          autoIncrement: true,
          comment: "主键ID"
        },
        username: {
          type: STRING(30),
          allowNull: false,
          defaultValue: "",
          comment: "用户名"
          // unique: true
        },
        avatar: {
          type: STRING(100),
          allowNull: false,
          defaultValue: "",
          comment: "头像"
        },
        email: {
          type: STRING(50),
          allowNull: false,
          defaultValue: "",
          comment: "邮箱"
        },
        phone: {
          type: STRING(11),
          allowNull: false,
          defaultValue: "",
          unique: true,
          comment: "手机号"
        },
        password: {
          type: STRING,
          allowNull: false,
          defaultValue: "",
          comment: "密码"
        },
        desc: {
          type: TEXT,
          allowNull: true,
          comment: "描述"
        },
        status: {
          type: ENUM("0", "1"),
          allowNull: false,
          defaultValue: "1",
          comment: "状态 0 禁用 1 启用"
        },
        gender: {
          type: ENUM("0", "1", "2"),
          allowNull: false,
          defaultValue: "0",
          comment: "性别 0 未知 1 男 2 女"
        },
        roleId: {
          type: INTEGER,
          allowNull: false,
          defaultValue: 1,
          comment: "角色ID"
        },
        memberId: {
          type: INTEGER,
          allowNull: false,
          defaultValue: 7,
          comment: "会员ID"
        },
        created_time: DATE,
        updated_time: DATE
      },
      {
        engine: "InnoDB",
        // autoIncrement: 10, // 锁定从哪开始递增
        charset: "utf8mb4",
        collate: "utf8mb4_general_ci"
      }
    );
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable("user");
  }
};
